// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TabViewModel.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the <seealso cref="TabViewModel" /> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Client.Common.BaseClasses
{
    using System;
    using System.Windows;

    using Microsoft.Practices.Prism;

    /// <summary>
    /// Defines the <seealso cref="TabViewModel"/> type.
    /// </summary>
    public class TabViewModel : ViewModelBase, IActiveAware
    {
        /// <summary>
        /// Using a DependencyProperty as the backing store for CanClose.  This enables animation, styling, binding, etc...
        /// </summary>
        public static readonly DependencyProperty CanCloseProperty = DependencyProperty.Register("CanClose", typeof(bool), typeof(TabViewModel));

        /// <summary>
        /// Using a DependencyProperty as the backing store for IsModified.  This enables animation, styling, binding, etc...
        /// </summary>
        public static readonly DependencyProperty IsModifiedProperty = DependencyProperty.Register("IsModified", typeof(bool), typeof(TabViewModel));

        /// <summary>
        /// Member variable _isActive
        /// </summary>
        private bool _isActive;

        /// <summary>
        /// Initializes a new instance of the <see cref="TabViewModel"/> class.
        /// </summary>
        public TabViewModel()
        {
            CanClose = true;
        }

        /// <summary>
        /// Occurs when [is active changed].
        /// </summary>
        public event EventHandler IsActiveChanged;

        /// <summary>
        /// Gets or sets a value indicating whether this instance is active.
        /// </summary>
        /// <value>
        ///   <c>true</c> if this instance is active; otherwise, <c>false</c>.
        /// </value>
        public bool IsActive
        {
            get
            {
                return _isActive;
            }

            set
            {
                RaisePropertyChangingEvent("IsActive");
                _isActive = value;
                RaisePropertyChangedEvent("IsActive");
                if (IsActiveChanged != null)
                {
                    IsActiveChanged(this, EventArgs.Empty);
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance can close.
        /// </summary>
        /// <value>
        ///   <c>true</c> if this instance can close; otherwise, <c>false</c>.
        /// </value>
        public bool CanClose
        {
            get { return (bool)GetValue(CanCloseProperty); }
            set { SetValue(CanCloseProperty, value); }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is modified.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is modified; otherwise, <c>false</c>.
        /// </value>
        public bool IsModified
        {
            get { return (bool)GetValue(IsModifiedProperty); }
            set { SetValue(IsModifiedProperty, value); }
        }
    }
}